package cn.jsj.cxsys.controller;

import org.springframework.stereotype.*;
import org.springframework.beans.factory.annotation.*;
import cn.jsj.cxsys.service.*;
import cn.jsj.cxsys.pojo.*;
import org.springframework.web.bind.annotation.*;
import cn.jsj.cxsys.controller.packageClass.*;
import java.util.*;

@CrossOrigin
@Controller
public class MessageTranslation
{
    @Autowired
    private StudentLabService studentLabService;
    @Autowired
    private TeacherLabService teacherLabService;

    @ResponseBody
    @RequestMapping(value = { "messages" }, method = { RequestMethod.POST })
    public List<LabMessage> getLabMessagesOfStudent(@RequestBody final Student student) {
        return (List<LabMessage>)this.studentLabService.getAllMessageStudent(student);
    }

    @ResponseBody
    @RequestMapping(value = { "notViewedMessages" }, method = { RequestMethod.POST })
    public List<LabMessage> getLabMessageOfStudentNotRead(@RequestBody final User_Page up) {
        if (up == null) {
            return null;
        }
        return (List<LabMessage>)this.studentLabService.getLabMessages(up.getUser(), up.getPageNum(), up.getPageSize());
    }

    @ResponseBody
    @RequestMapping(value = { "notViewedMessagesOfTeacher" }, method = { RequestMethod.POST })
    public List<LabMessage> getLabMessageOFTeacherNotRead(@RequestBody final User_Page up) {
        if (up == null) {
            return null;
        }
        return (List<LabMessage>)this.teacherLabService.getNotSeeLabMessage(up.getUser(), up.getPageNum(), up.getPageSize());
    }

    @ResponseBody
    @RequestMapping(value = { "judgeApply" }, method = { RequestMethod.POST })
    public String judgeApply(@RequestBody final Teacher_ResponseLab tr) {
        if (tr == null) {
            return "paramLess";
        }
        return this.teacherLabService.judgeStudentApply(tr.getTeacher(), tr.getLabMessage());
    }

    @ResponseBody
    @RequestMapping(value = { "deleteMessageOfStudent" }, method = { RequestMethod.POST })
    public String deleteOneMessageOfStudent(@RequestBody final Student_ApplyLab ui) {
        if (ui == null) {
            return "paramLess";
        }
        return this.studentLabService.deleteOneMessage((User)ui.getStudent(), ui.getLabMessage());
    }

    @ResponseBody
    @RequestMapping(value = { "superGetLabMessage" }, method = { RequestMethod.POST }, params = { "superAccount", "password", "page", "rows" })
    public EasyUIPages<LabMessage> getAllLabMessage(@RequestParam("superAccount") final String account, @RequestParam("password") final String password, @RequestParam("page") final int pageNum, @RequestParam("rows") final int pageSize) {
        final List<LabMessage> tt = (List<LabMessage>)this.teacherLabService.superLaderGetLabMessage(account, password, pageNum, Integer.MAX_VALUE);
        if (tt != null) {
            Collections.sort(tt);
        }
        final int messageNumber = this.teacherLabService.getMessageNumber();
        return new EasyUIPages<LabMessage>(messageNumber, tt);
    }
}
